The present invention relates to a computer system and method for testing and debugging computer programs. More specifically, the present invention is directed to a method and system for emulating hardware for analyzing memory references.
Reliable and successful software is built through sound, efficient and thorough testing. However, software testing is labor intensive and expensive and accounts for a substantial portion of commercial software development costs. At the same time, software testing is critical and necessary to achieving quality software. Typically, software testing includes test suite generation, test suite execution validation, and regression testing.
The size and sophistication of computer programs have substantially increased over time. As a result, the need for more flexible and sophisticated testing and debugging tools has also increased. Memory access related errors are one of the most important errors which must be watched and corrected. The current practice for testing and debugging programs include having the compiler output extra instructions for debugging purposes or to post-process the object files. These approaches require pre-processing of the program which is cumbersome, requires larger storage, and is time consuming.
Therefore, what is needed is a test tool for assisting programmers in testing software programs that is capable of directly emulating the preexisting instructions and not inserting (storing) new instructions into (the storage occupied by) preexisting machine code.
The present invention is a software system that detects large classes of programming and run-time errors, including algorithmic anomalies, bugs, and deficiencies in a computer program. By emulating the hardware platform and monitoring the execution of a program and the concurrent data manipulation, the tool helps developers understand how their code behaves while requiring less test preparation time and less storage. The software system locates bugs in binary object executable programs. Working on the binary object executable program at runtime, the tool verifies memory references and program implementation by monitoring each logical memory access for data. The software tool works directly with any executable program, and does not require source or relocatable object code. This is an advantage when pieces of the program are provided by others, who may furnish only xe2x80x9cshared librariesxe2x80x9d or other forms which are not relocatable object code, and not source code.
In one embodiment, the software tool of the present invention is a software emulation of hardware that analyzes software by checking all data memory accesses made by an application process running on specific operating systems. When an improper behavior is detected by the tool, the tool issues an error message identifying the kind of error and where it occurred. Improper behavior may be any access to a logically unallocated region, errors or abuses of the dynamic memory allocation protocol, and the like.
In one aspect, the present invention describes a method for analyzing a computer program for execution on a target hardware platform. The method comprises the steps of emulating the target hardware platform by a computer software; fetching an instruction included in the computer program; decoding the fetched instruction; executing the decoded instruction; and monitoring data manipulation by the emulated hardware platform of the executed instruction.